
*********************************
** USE THIS DO FILE TO RUN MAIN MANUSCRIPT ANALYSES
** CREATED: DEC 2023
** BY: CC
*********************************

*****************
* PROGRAM SETUP *
*****************


version 18
clear all
set more off
set scheme plotplainblind, permanently

***************
* DIRECTORIES *
***************

global pathown = "/Users/cavaille/Dropbox/CO.who_cares/2.Data and Analyses"

global pathcode = "$pathown/7.Replication file PSRM"
global pathtemp = "$pathown/7.Replication file PSRM/temp"
global pathout = "$pathown/7.Replication file PSRM/out"
global pathfig = "$pathown/7.Replication file PSRM/fig"
global pathtab = "$pathown/7.Replication file PSRM/tab"


log using "$pathcode/log_main.log", replace



****** build dataset 
qui do "$pathcode/0.build_dataset_F.do"


*----- 
*-------------------------------
*---  Figure 1 -- This is a screenshot of QVSR tool, no code needed



*----- 
*-------------------------------
*---  Figure 2 -- 

*** note that for presentational purposes, for Likert+, 2 observations from one very parsely populated response categorie (= 5, 2 obs total) are dropped to compute the figure. These 2 individuals both donated 100 dollars, which messes up the Y-axis.

cd "$pathtemp"

gen temp_LPP3 = votes_gunw1LPP3N
replace temp_LPP3 = . if votes_gunw1LPP3 == 5 & method == 2
gen temp_don_C_gun  = don_C_gun 
replace temp_don_C_gun = . if votes_gunw1LPP3 == 5 & method == 2


egen mean_gunL = mean(don_C_gun) if method == 1 , by(votes_gunw1LPP3N)
egen mean_gunLp = mean(temp_don_C_gun) if method == 2 , by(temp_LPP3)
egen mean_gunQV = mean(don_C_gun) if method == 3 , by(votes_gunw1LPP3N)

egen count_gun = count(votes_gunw1N), by(method votes_gunw1LPP3N)
egen count_gunLPP3 = count(votes_gunw1N) if method == 2, by(temp_LPP3)


tw (lfitci don_C_gun votes_gunw1LPP3N if method == 1,  level(95) clp(shortdash) clc(black) yline(-20) yline(20)) ///
(scatter mean_gunL votes_gunw1LPP3N if method == 1 [w=count_gun],  mc(black)  msymbol(oh) ///
ylabel(-40(20)40 , angle(horizontal)labsize(medsmall)) yline(0) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert")  legend(off) )
graph save "gun_fig2L.gph", replace 


tw (lfitci temp_don_C_gun temp_LPP3 if method == 2,  level(95) clp(dash_dot) clc(black) yline(-20) yline(20)) ///
(scatter mean_gunLp temp_LPP3 if method == 2 [w=count_gunLPP3],  mc(black)  msymbol(oh) ///
ylabel(-40(20)40 , angle(horizontal)labsize(medsmall)) yline(0) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert +, ")  legend(off) )
graph save "gun_fig2Lpp3.gph", replace 


tw (lfitci don_C_gun votes_gunw1LPP3N if method == 3,  level(95) clp(shortdash) clc(black) yline(-20) yline(20)) ///
(scatter mean_gunQV votes_gunw1LPP3N if method == 3 [w=count_gun],  mc(black)  msymbol(oh) ///
ylabel(-40(20)40 , angle(horizontal)labsize(medsmall)) yline(0) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("QVSR")  legend(off) )
graph save "gun_fig2QV.gph", replace 


**** figures below 


gr tw (hist votes_gunw1LPP3N if  method == 1, frac ///
discrete bfcolor(teal)  blcolor(white) title("")) ,  leg(off)  ///
graphr(fc(white) lc(white) ifc(white) ilc(white)) title("", size(medium)) yti("") xti("") ///
ysc(range(0 .5)) ylab(0(.1).5)	///
xsc(range(0 1)) xlab(0(0.1)1) fysize(20) 
graph save "gunLw1N.gph", replace 
	
gr tw (hist votes_gunw1LPP3N if  method == 2, frac ///
discrete bfcolor(teal)  blcolor(white) title("")) ,  leg(off)  ///
graphr(fc(white) lc(white) ifc(white) ilc(white)) title("", size(medium)) yti("") xti("") ///
ysc(range(0 .5)) ylab(0(.1).5)	///
xsc(range(0 1)) xlab(0(0.1)1) fysize(20) 
graph save "gunLpp3w1N.gph", replace 

gr tw (hist votes_gunw1LPP3N if  method == 3, frac ///
discrete bfcolor(teal)  blcolor(white) title("")) ,  leg(off)  ///
graphr(fc(white) lc(white) ifc(white) ilc(white)) title("", size(medium)) yti("") xti("") ///
ysc(range(0 .5)) ylab(0(.1).5)	///
xsc(range(0 1)) xlab(0(0.1)1) fysize(20) 
graph save "gunQVw1N.gph", replace 


graph combine  "gun_fig2Lpp3.gph"  "gun_fig2L.gph" "gun_fig2QV.gph"  ///
 "gunLpp3w1N.gph" "gunLw1N.gph" "gunQVw1N.gph" , ///
col(3) title("", size(zero)) 
cd "$pathfig"
graph export "Fig2.pdf", replace

erase "$pathtemp/gun_fig2L.gph"
erase "$pathtemp/gun_fig2Lpp3.gph"
erase "$pathtemp/gun_fig2QV.gph"
erase "$pathtemp/gunLpp3w1N.gph"
erase "$pathtemp/gunLw1N.gph"
erase "$pathtemp/gunQVw1N.gph"


*----- 
*-------------------------------
*---  Figure 3 -- 

cd "$pathtemp"

matrix EV_fig3 = J(6,6,0)
matrix colnames EV_fig3 = "Likert" " " "Likert +" " " "QVSR" " " 
matrix rownames EV_fig3 = "Gun-related Donations" ///
"Immigration-related Donations" ///
"Minimum Wage-related Writing" /// 
"Abortion-related Writing" ///
"Punish abs" ///
"Punish proportion"


regress don_C_gunST c.votes_gunw1LPP3N##i.method i.block
lincom c.votes_gunw1LPP3N + 1.method#c.votes_gunw1LPP3N 
matrix EV_fig3[1,1] = r(estimate)
matrix EV_fig3[1,2] = r(se)
lincom c.votes_gunw1LPP3N + 2.method#c.votes_gunw1LPP3N 
matrix EV_fig3[1,3] = r(estimate)
matrix EV_fig3[1,4] = r(se)
lincom c.votes_gunw1LPP3N + 3.method#c.votes_gunw1LPP3N 
matrix EV_fig3[1,5] = r(estimate)
matrix EV_fig3[1,6] = r(se)


regress don_C_wall_inST c.votes_wall_inw1LPP3N##i.method  i.block
lincom c.votes_wall_inw1LPP3N + 1.method#c.votes_wall_inw1LPP3N 
matrix EV_fig3[2,1] = r(estimate)
matrix EV_fig3[2,2] = r(se)
lincom c.votes_wall_inw1LPP3N + 2.method#c.votes_wall_inw1LPP3N 
matrix EV_fig3[2,3] = r(estimate)
matrix EV_fig3[2,4] = r(se)
lincom c.votes_wall_inw1LPP3N + 3.method#c.votes_wall_inw1LPP3N 
matrix EV_fig3[2,5] = r(estimate)
matrix EV_fig3[2,6] = r(se)


regress writing_minWNST c.abs_votes_minWw1LPP3N##i.method  i.block
lincom c.abs_votes_minWw1LPP3N + 1.method#c.abs_votes_minWw1LPP3N 
matrix EV_fig3[3,1] = r(estimate)
matrix EV_fig3[3,2] = r(se)
lincom c.abs_votes_minWw1LPP3N + 2.method#c.abs_votes_minWw1LPP3N 
matrix EV_fig3[3,3] = r(estimate)
matrix EV_fig3[3,4] = r(se)
lincom c.abs_votes_minWw1LPP3N + 3.method#c.abs_votes_minWw1LPP3N 
matrix EV_fig3[3,5] = r(estimate)
matrix EV_fig3[3,6] = r(se)


regress writing_abortionNST c.abs_votes_abortion_inw1LPP3N##i.method  i.block, 
lincom c.abs_votes_abortion_inw1LPP3N + 1.method#c.abs_votes_abortion_inw1LPP3N 
matrix EV_fig3[4,1] = r(estimate)
matrix EV_fig3[4,2] = r(se)
lincom c.abs_votes_abortion_inw1LPP3N + 2.method#c.abs_votes_abortion_inw1LPP3N 
matrix EV_fig3[4,3] = r(estimate)
matrix EV_fig3[4,4] = r(se)
lincom c.abs_votes_abortion_inw1LPP3N + 3.method#c.abs_votes_abortion_inw1LPP3N 
matrix EV_fig3[4,5] = r(estimate)
matrix EV_fig3[4,6] = r(se)


regress punish_FaST c.diffLPP3N##i.method  i.block
lincom c.diffLPP3N + 1.method#c.diffLPP3N 
matrix EV_fig3[5,1] = r(estimate)
matrix EV_fig3[5,2] = r(se)
lincom c.diffLPP3N + 2.method#c.diffLPP3N 
matrix EV_fig3[5,3] = r(estimate)
matrix EV_fig3[5,4] = r(se)
lincom c.diffLPP3N + 3.method#c.diffLPP3N 
matrix EV_fig3[5,5] = r(estimate)
matrix EV_fig3[5,6] = r(se)


regress proportionST c.diffLPP3N##i.method i.block
lincom c.diffLPP3N + 1.method#c.diffLPP3N 
matrix EV_fig3[6,1] = r(estimate)
matrix EV_fig3[6,2] = r(se)
lincom c.diffLPP3N + 2.method#c.diffLPP3N 
matrix EV_fig3[6,3] = r(estimate)
matrix EV_fig3[6,4] = r(se)
lincom c.diffLPP3N + 3.method#c.diffLPP3N 
matrix EV_fig3[6,5] = r(estimate)
matrix EV_fig3[6,6] = r(se)



putexcel set  "$pathtemp/EV_fig3", replace
putexcel A1=matrix(EV_fig3) 


preserve

clear all

cd "$pathtemp"
import excel EV_fig3

gen topic = _n


rename A est1
rename B se1
rename C est2
rename D se2
rename E est3
rename F se3

reshape long est se, i(topic) j(method)    

sort topic method
gen order = _n
gen lb = est - 1.96*se
gen ub = est + 1.96*se


tw (scatter est order,  legend(off) ylabel(0(0.2)2.2) yline(0, lc(black) lstyle(gs15)) ///
text(2.2 1.5 "Gun", place(e)) ///
text(2.2 3.9 "Immigration", place(e)) ///
text(2.2 7.2 "Minimum", place(e)) ///
text(2.0 7.4 "Wage", place(e)) ///
text(2.2 10 "Abortion", place(e)) ///
text(2.2 12.5 "DG punish (1)", place(e)) ///
text(2.2 15.8 "DG punish (2)", place(e)) ///
xlabel(1 "Likert" 2 "Likert +" 3 "QVSR" 4 " " 5 " " 6 " " 7 "Likert" 8 "Likert +" 9 "QVSR" ///
10 " " 11 " " 12 " " 13 "Likert" 14 "Likert +" 15 "QVSR" 16 " " 17 " " 18 " " , angle(45)labsize(small) ) ///
xtitle(" ", size(zero))) ///
(rcap lb ub order, xline(3.5) xline(6.5) xline(9.5) xline(12.5) xline(15.5))


cd "$pathfig"
graph export "Fig3.pdf", replace 


restore


erase "$pathtemp/EV_fig3.xlsx"




*----- 
*-------------------------------
*---  Figure 4 -- 


*-- recode and rename to help with coding 

recode sex (1 = 0) (2 =1), gen(Gender)

egen mean_GenderL = mean(Gender) if method == 1 , by(votes_genderw1LPP3N)
egen mean_GenderLp = mean(Gender) if method == 2 , by(votes_genderw1LPP3N)
egen mean_GenderQV = mean(Gender) if method == 3 , by(votes_genderw1LPP3N)


egen count_Gender = count(votes_genderw1LPP3N), by(method votes_genderw1LPP3N)


cd "$pathtemp"

tw (lfitci Gender votes_genderw1LPP3N if method == 1,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_GenderL votes_genderw1LPP3N if method == 1 [w=count_Gender],  mc(black)  msymbol(oh) ///
ylabel(-0.2(0.2)1, angle(horizontal) labsize(medsmall)) yline(0.50) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert")  legend(off) )
graph save "Gender_fig4L.gph", replace 


tw (lfitci Gender votes_genderw1LPP3N if method == 2,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_GenderLp votes_genderw1LPP3N if method == 2 [w=count_Gender],  mc(black)  msymbol(oh) ///
ylabel(-0.2(0.2)1 , angle(horizontal) labsize(medsmall)) yline(0.50) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert +")  legend(off) )
graph save "Gender_fig4Lpp3.gph", replace 


tw (lfitci Gender votes_genderw1LPP3N if method == 3,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_GenderQV votes_genderw1LPP3N if method == 3 [w=count_Gender],  mc(black)  msymbol(oh) ///
ylabel(-0.2(0.2)1, angle(horizontal) labsize(medsmall)) yline(0.50) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("QVSR")  legend(off) )
graph save "Gender_fig4QV.gph", replace 


*** quadratic 


tw (qfitci Gender votes_genderw1LPP3N if method == 1,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_GenderL votes_genderw1LPP3N if method == 1 [w=count_Gender],  mc(black)  msymbol(oh) ///
ylabel(-0.2(0.2)1 , angle(horizontal) labsize(medsmall)) yline(0.50) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert")  legend(off) )
graph save "Gender_fig4L_qua.gph", replace 


tw (qfitci Gender votes_genderw1LPP3N if method == 2,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_GenderLp votes_genderw1LPP3N if method == 2 [w=count_Gender],  mc(black)  msymbol(oh) ///
ylabel(-0.2(0.2)1 , angle(horizontal) labsize(medsmall)) yline(0.50) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert +")  legend(off) )
graph save "Gender_fig4Lpp3_qua.gph", replace 


tw (qfitci Gender votes_genderw1LPP3N if method == 3,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_GenderQV votes_genderw1LPP3N if method == 3 [w=count_Gender],  mc(black)  msymbol(oh) ///
ylabel(-0.2(0.2)1, angle(horizontal)labsize(medsmall)) yline(0.50) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("QVSR")  legend(off) )
graph save "Gender_fig4QV_qua.gph", replace 

graph combine  "Gender_fig4Lpp3.gph"  "Gender_fig4L.gph" "Gender_fig4QV.gph" ///
 "Gender_fig4Lpp3_qua.gph"  "Gender_fig4L_qua.gph" "Gender_fig4QV_qua.gph", col(3)
cd "$pathfig"
graph export "Fig4.pdf", replace 


erase "$pathtemp/Gender_fig4Lpp3.gph"  
erase "$pathtemp/Gender_fig4L.gph" 
erase "$pathtemp/Gender_fig4QV.gph" 
erase "$pathtemp/Gender_fig4Lpp3_qua.gph"  
erase "$pathtemp/Gender_fig4L_qua.gph" 
erase "$pathtemp/Gender_fig4QV_qua.gph"



*----- 
*-------------------------------
*---  Figure 5 -- 




egen mean_paidLL = mean(child2) if method == 1 , by(votes_paidLw1LPP3N)
egen mean_paidLLp = mean(child2) if method == 2 , by(votes_paidLw1LPP3N)
egen mean_paidLQV = mean(child2) if method == 3 , by(votes_paidLw1LPP3N)

egen count_paidL = count(votes_paidLw1LPP3N), by(method votes_paidLw1LPP3N)

cd "$pathtemp"

tw (lfitci child2 votes_paidLw1LPP3N if method == 1,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_paidLL votes_paidLw1LPP3N if method == 1 [w=count_paidL],  mc(black)  msymbol(oh) ///
ylabel(0.8(0.4)2.8, angle(horizontal) labsize(medsmall) ) yline(1.56) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert", size(med))  legend(off) )
graph save "paidL_fig5L.gph", replace 


tw (lfitci child2 votes_paidLw1LPP3N if method == 2,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_paidLLp votes_paidLw1LPP3N if method == 2 [w=count_paidL],  mc(black)  msymbol(oh) ///
ylabel(0.8(0.4)2.8 , angle(horizontal)labsize(medsmall)) yline(1.56) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("Likert +", size(med))  legend(off) )
graph save "paidL_fig5Lpp3.gph", replace 


tw (lfitci child2 votes_paidLw1LPP3N if method == 3,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_paidLQV votes_paidLw1LPP3N if method == 3 [w=count_paidL],  mc(black)  msymbol(oh) ///
ylabel(0.8(0.4)2.8, angle(horizontal) labsize(medsmall)) yline(1.56) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("QVSR", size(med))  legend(off) )
graph save "paidL_fig5QV.gph", replace 


*** quadratic 


tw (qfitci child2 votes_paidLw1LPP3N if method == 1,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_paidLL votes_paidLw1LPP3N if method == 1 [w=count_paidL],  mc(black)  msymbol(oh) ///
ylabel(0.8(0.4)2.8 , angle(horizontal) labsize(medsmall)) yline(1.56) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("")  legend(off) )
graph save "paidL_fig5L_qua.gph", replace 


tw (qfitci child2 votes_paidLw1LPP3N if method == 2,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_paidLLp votes_paidLw1LPP3N if method == 2 [w=count_paidL],  mc(black)  msymbol(oh) ///
ylabel(0.8(0.4)2.8 , angle(horizontal) labsize(medsmall)) yline(1.56) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("")  legend(off) )
graph save "paidL_fig5Lpp3_qua.gph", replace 


tw (qfitci child2 votes_paidLw1LPP3N if method == 3,  level(95) clp(shortdash) clc(black) ) ///
(scatter mean_paidLQV votes_paidLw1LPP3N if method == 3 [w=count_paidL],  mc(black)  msymbol(oh) ///
ylabel(0.8(0.4)2.8, angle(horizontal) labsize(medsmall)) yline(1.56) xlabel(0(0.1)1, angle(horizontal)labsize(medsmall)) ///
ytitle("", size(medsmall)) xtitle("", size(medsmall)) ///
title("")  legend(off) )
graph save "paidL_fig5QV_qua.gph", replace 


graph combine  "paidL_fig5Lpp3.gph"  "paidL_fig5L.gph" "paidL_fig5QV.gph" ///
 "paidL_fig5Lpp3_qua.gph"  "paidL_fig5L_qua.gph" "paidL_fig5QV_qua.gph", col(3)
 cd "$pathfig"
graph export "Fig5.pdf", replace 


erase "$pathtemp/paidL_fig5Lpp3.gph"  
erase "$pathtemp/paidL_fig5L.gph" 
erase "$pathtemp/paidL_fig5QV.gph" 
erase "$pathtemp/paidL_fig5Lpp3_qua.gph"  
erase "$pathtemp/paidL_fig5L_qua.gph" 
erase "$pathtemp/paidL_fig5QV_qua.gph"





*----- 
*-------------------------------
*---  Table 2  -- 



matrix EV_tab2 = J(3,6,0)
matrix colnames EV_tab2 = "QVSR vs Likert" "Likert+ vs Likert" "QVSR vs LIkert+" "QVSR vs Likert" "Likert+ vs Likert" "QVSR vs LIkert+" 
matrix rownames EV_tab2 = "N" ///
"F test" ///
"Prob > F "


***------sureg wave 1 

*--- Likert versus QVSR


local var LPP3
foreach var in `var' {
	
	
preserve

drop if method == 2

recode method (1 = 0) (3 = 1)

qui sureg (don_C_gunST c.votes_gunw1`var'N##i.method i.block) ///
(don_C_wall_inST c.votes_wall_inw1`var'N##i.method i.block), small dfk coeflegend 
parmest, saving("$pathtemp/est_tab2_LQV_w1", replace)  stars(0.1 0.05 0.01)
matrix EV_tab2[1,1] = e(N)

test _b[don_C_gunST:1.method#c.votes_gunw1`var'N] + _b[don_C_wall_inST:1.method#c.votes_wall_inw1`var'N] = 0
matrix EV_tab2[2,1] = r(F)
matrix EV_tab2[3,1] = r(p)

restore 


*--- Likert versus Likert+
	
	
preserve

drop if method == 3

recode method (1 = 0) (2 = 1)

qui  sureg (don_C_gunST c.votes_gunw1`var'N##i.method i.block) ///
(don_C_wall_inST c.votes_wall_inw1`var'N##i.method i.block), small dfk coeflegend 
parmest, saving("$pathtemp/est_tab2_LLp_w1", replace)  stars(0.1 0.05 0.01)
matrix EV_tab2[1,2] = e(N)


test _b[don_C_gunST:1.method#c.votes_gunw1`var'N] + _b[don_C_wall_inST:1.method#c.votes_wall_inw1`var'N] = 0
matrix EV_tab2[2,2] = r(F)
matrix EV_tab2[3,2] = r(p)

restore 


*--- Libert+ versus QVSR
	
	
preserve

drop if method == 1

recode method (2 = 0) (3 = 1)

qui  sureg (don_C_gunST c.votes_gunw1`var'N##i.method i.block) ///
(don_C_wall_inST c.votes_wall_inw1`var'N##i.method i.block), small dfk coeflegend 
parmest, saving("$pathtemp/est_tab2_LpQV_w1", replace)  stars(0.1 0.05 0.01)
matrix EV_tab2[1,3] = e(N)

test _b[don_C_gunST:1.method#c.votes_gunw1`var'N] + _b[don_C_wall_inST:1.method#c.votes_wall_inw1`var'N] = 0
matrix EV_tab2[2,3] = r(F)
matrix EV_tab2[3,3] = r(p)

restore 


***----- sureg wave 2 
*--- Likert versus QVSR

preserve

drop if method == 2

recode method (1 = 0) (3 = 1)

qui  sureg (writing_minWNST c.abs_votes_minWw1`var'N##i.method i.block) ///
(writing_abortionNST c.abs_votes_abortion_inw1`var'N##i.method i.block) ///
(punish_FaST c.diff`var'N##i.method i.block) ///
(proportionST c.diff`var'N##i.method i.block), small dfk coeflegend 
parmest, saving("$pathtemp/est_tab2_LQV_w2", replace)  stars(0.1 0.05 0.01)
matrix EV_tab2[1,4] = e(N)
 
test _b[writing_minWNST:abs_votes_minWw1`var'N#1.method] + ///
_b[writing_abortionNST:abs_votes_abortion_inw1`var'N#1.method] + ///
_b[punish_FaST:diff`var'N#1.method] + ///
_b[proportionST:diff`var'N#1.method] = 0
matrix EV_tab2[2,4] = r(F)
matrix EV_tab2[3,4] = r(p)

restore 


*--- Likert versus Likert+

preserve

drop if method == 3

recode method (1 = 0) (2 = 1)

qui sureg (writing_minWNST c.abs_votes_minWw1`var'N##i.method i.block) ///
(writing_abortionNST c.abs_votes_abortion_inw1`var'N##i.method i.block) ///
(punish_FaST c.diff`var'N##i.method i.block) ///
(proportionST c.diff`var'N##i.method i.block), small dfk coeflegend 
parmest, saving("$pathtemp/est_tab2_LLp_w2", replace)  stars(0.1 0.05 0.01)
matrix EV_tab2[1,5] = e(N)
 
 
test _b[writing_minWNST:abs_votes_minWw1`var'N#1.method] + ///
_b[writing_abortionNST:abs_votes_abortion_inw1`var'N#1.method] + ///
_b[punish_FaST:diff`var'N#1.method] + ///
_b[proportionST:diff`var'N#1.method] = 0
matrix EV_tab2[2,5] = r(F)
matrix EV_tab2[3,5] = r(p)

restore 


*--- Libert+ versus QVSR

preserve

drop if method == 1

recode method (2 = 0) (3 = 1)

qui sureg (writing_minWNST c.abs_votes_minWw1`var'N##i.method i.block) ///
(writing_abortionNST c.abs_votes_abortion_inw1`var'N##i.method i.block) ///
(punish_FaST c.diff`var'N##i.method i.block)  ///
(proportionST c.diff`var'N##i.method i.block), small dfk coeflegend 
parmest, saving("$pathtemp/est_tab2_LpQV_w2", replace)  stars(0.1 0.05 0.01)
matrix EV_tab2[1,6] = e(N)

test _b[writing_minWNST:abs_votes_minWw1`var'N#1.method] + ///
_b[writing_abortionNST:abs_votes_abortion_inw1`var'N#1.method] + ///
_b[punish_FaST:diff`var'N#1.method] + ///
_b[proportionST:diff`var'N#1.method] = 0
matrix EV_tab2[2,6] = r(F)
matrix EV_tab2[3,6] = r(p)

restore 

}



use "$pathtemp/est_tab2_LQV_w1", clear
gen col = "col1"
keep if parm == "1.method#c.votes_gunw1LPP3N" | parm == "1.method#c.votes_wall_inw1LPP3N"
	rename parm variable
	rename stderr se
	rename estimate b
save "$pathtemp/est_tab2_LQV_w1", replace

use "$pathtemp/est_tab2_LLp_w1", clear
gen col = "col2"
keep if parm == "1.method#c.votes_gunw1LPP3N" | parm == "1.method#c.votes_wall_inw1LPP3N"
	rename parm variable
	rename stderr se
	rename estimate b
save "$pathtemp/est_tab2_LLp_w1", replace

use "$pathtemp/est_tab2_LpQV_w1", clear
gen col = "col3"
keep if parm == "1.method#c.votes_gunw1LPP3N" | parm == "1.method#c.votes_wall_inw1LPP3N"
	rename parm variable
	rename stderr se
	rename estimate b
save "$pathtemp/est_tab2_LpQV_w1", replace


use "$pathtemp/est_tab2_LQV_w2", clear
gen col = "col4"
keep if parm == "1.method#c.abs_votes_minWw1LPP3N" | parm == "1.method#c.abs_votes_abortion_inw1LPP3N" ///
| parm == "1.method#c.diffLPP3N" | parm == "1.method#c.diffLPP3N"
	rename parm variable
	rename stderr se
	rename estimate b
save "$pathtemp/est_tab2_LQV_w2", replace

use "$pathtemp/est_tab2_LLp_w2", clear
gen col = "col5"
keep if parm == "1.method#c.abs_votes_minWw1LPP3N" | parm == "1.method#c.abs_votes_abortion_inw1LPP3N" ///
| parm == "1.method#c.diffLPP3N" | parm == "1.method#c.diffLPP3N"
	rename parm variable
	rename stderr se
	rename estimate b
save "$pathtemp/est_tab2_LLp_w2", replace

use "$pathtemp/est_tab2_LpQV_w2", clear
gen col = "col6"
keep if parm == "1.method#c.abs_votes_minWw1LPP3N" | parm == "1.method#c.abs_votes_abortion_inw1LPP3N" ///
| parm == "1.method#c.diffLPP3N" | parm == "1.method#c.diffLPP3N"
	rename parm variable
	rename stderr se
	rename estimate b
save "$pathtemp/est_tab2_LpQV_w2", replace


use "$pathtemp/est_tab2_LQV_w1", clear
append using "$pathtemp/est_tab2_LLp_w1"
append using "$pathtemp/est_tab2_LpQV_w1"
append using "$pathtemp/est_tab2_LQV_w2"
append using "$pathtemp/est_tab2_LLp_w2"
append using "$pathtemp/est_tab2_LpQV_w2"





**************
**************
** LATEX code for Table 2 is in "tab2_raw.tex", please check "tab" folder, tab2.tex
**************
**************

log close

set linesize 255
quietly {
capture log close
log using "$pathtab/Tab2.tex", text replace
noisily display "\begin{table}"
noisily display "\centering"
noisily display "\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"
noisily display "\def\onepc{$^{\ast\ast}$} \def\fivepc{$^{\ast}$}"
noisily display "\def\zeropc{$^{\ast\ast\ast}$}"
noisily display "\footnotesize"
noisily display "\caption{Differences in Coefficient Size (Seemingly Unrelated Models)  \label{tab:sureg}}"
noisily display "\begin{tabular}{l*{6}{l}}"
noisily display "\hline"
noisily display "\hline"
noisily display "  &QVSR  &Likert+  &QVSR  &QVSR &Likert+  &QVSR  \\"
noisily display "  &vs. & vs. & vs. & vs. & vs. & vs.  \\"
noisily display "  & Likert& Likert&LIkert+&Likert& Likert& LIkert+\\"
noisily display " \hline "
noisily display "Gun         &"   %9.2fc b[1] ""stars[1]  "&"     %9.2fc b[3] "" stars[3]  "&"      %9.2fc b[5] "" stars[5] "&"        "&"        "&"       "\\"
noisily display"&"  %9.2fc se[1]  "&" %9.2fc se[3] "&"  %9.2fc se[5] "&" "&" "&" "\\"
noisily display "Immigration &"         %9.2fc b[2] "" stars[2]  "&"    %9.2fc b[4] "" stars[4] "&" %9.2fc b[6] "" stars[6] "&"      "&"       "&"       "\\"
noisily display" &"  %9.2fc se[2]  "&" %9.2fc se[4] "&" %9.2fc se[6] "&" "&" "&" "\\"
noisily display "Minimum Wage&"        "&"        "&"        "&"        %9.2fc b[7] "" stars[7] "&"  %9.2fc b[11] "" stars[11] "&"      %9.2fc b[15] "" stars[15] "\\"
noisily display "&" "&" "&" "&"%9.2fc se[7] "&" %9.2fc se[11] "&" %9.2fc se[15] "\\"
noisily display "Abortion    &"        "&"       "&"        "&"         %9.2fc b[8] "" stars[8] "&"         %9.2fc b[12] "" stars[12] "&"       %9.2fc b[16] "" stars[16] "\\"
noisily display "&" "&" "&" "&" %9.2fc se[8] "&" %9.2fc se[12] "&" %9.2fc se[16] "\\"
noisily display "DG Punish (1)&"        "&"       "&"        "&"               %9.2fc b[9] "" stars[9] "&"         %9.2fc b[13] "" stars[13] "&"       %9.2fc b[17] "" stars[17] "\\"
noisily display "&" "&" "&" "&" %9.2fc se[9] "&" %9.2fc se[13] "&" %9.2fc se[17] "\\"
noisily display "DG Punish (2)&"        "&"       "&"       "&"        %9.2fc b[10] "" stars[10] "&"       %9.2fc b[14] "" stars[14] "&"       %9.2fc b[18] "" stars[18] "\\"
noisily display "&" "&" "&" "&" %9.2fc se[10] "&" %9.2fc se[14] "&" %9.2fc se[18] "\\"
noisily display " \hline "
noisily display "N           &"   %9.0fc  EV_tab2[1,1] "&"   %9.0fc EV_tab2[1,2] "&"   %9.0fc  EV_tab2[1,3] "&"    %9.0fc  EV_tab2[1,4] "&"  %9.0fc   EV_tab2[1,5] "&"   %9.0fc   EV_tab2[1,6] "\\"
noisily display "F test      &"   %9.2fc  EV_tab2[2,1] "&"  %9.2fc  EV_tab2[2,2] "&"   %9.2fc  EV_tab2[2,3] "&"    %9.2fc  EV_tab2[2,4] "&"  %9.2fc   EV_tab2[2,5] "&"   %9.2fc   EV_tab2[2,6] "\\"
noisily display "Prob > F    &"   %9.3fc  EV_tab2[3,1] "&"  %9.3fc  EV_tab2[3,2] "&"   %9.3fc  EV_tab2[3,3] "&"    %9.3fc  EV_tab2[3,4] "&"   %9.3fc  EV_tab2[3,5] "&"    %9.3fc  EV_tab2[3,6] "\\"
noisily display "\hline"
noisily display "\hline"
noisily display "\end{tabular}"
noisily display "\begin{tablenotes}[online]"
noisily display "\begin{scriptsize}"
noisily display "\item  \fivepc \$p\$\textless.05, \onepc \$p\$\textless.01 \zeropc \$p\$\textless.001. We replicate Figure 3 analysis using seemingly unrelated models. This table reports the interaction between the preference variable and a dummy variable identifying the survey methods used. For example, for the gun donation outcome, the difference between the coefficient for Likert and that for QVSR is equal to 0.59. Bottom row: F-test for the null-hypothesis that the sum of the coefficients is equal to 0."   
noisily display "\end{scriptsize}"
noisily display "\end{tablenotes}"
noisily display "\end{table}"
log close
}



erase "$pathtemp/est_tab2_LQV_w1.dta"
erase "$pathtemp/est_tab2_LLp_w1.dta"
erase "$pathtemp/est_tab2_LpQV_w1.dta"
erase "$pathtemp/est_tab2_LQV_w2.dta"
erase "$pathtemp/est_tab2_LLp_w2.dta"
erase "$pathtemp/est_tab2_LpQV_w2.dta"




